package main

import (
	"github.com/pkg/errors"
	"net/rpc"
	"net/http"
	"net"
	"log"
)

type Args struct{
	A,B int
}
type Quotient struct{
	Quo,Rem int
}
type Arith int
func (t *Arith) Multiply(args *Args,reply *int) error{
	*reply=args.A*args.B
	return nil
}
func (t *Arith) Didvide(args *Args,quo *Quotient) error{
	if args.B==0{
		return errors.New("divide by zero")
	}
	quo.Quo=args.A/args.B
	quo.Rem=args.A%args.B
	return nil
}
func main() {
	arith:=new(Arith)
	rpc.Register(arith)
	rpc.HandleHTTP()
	l,e:=net.Listen("tcp",":1234")
	if e!=nil{
		log.Fatal("listen error :" ,e)
	}
	go http.Serve(l,nil)
}